package com.itheima.service.impl;

import com.alibaba.dubbo.config.annotation.Service;
import com.itheima.dao.HealthInterventionDao;
import com.itheima.pojo.Exercise;
import com.itheima.pojo.Food;
import com.itheima.pojo.Intervention;
import com.itheima.service.HealthInterventionService;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;
@Service
public class HealthInterventionServiceImpl implements HealthInterventionService {
    @Autowired
    private HealthInterventionDao healthInterventionDao;
    @Override
    public List<Exercise> querySport() {
        List<Exercise> list = healthInterventionDao.querySport();
        return list;
    }

    @Override
    public List<Food> queryFood() {
        List<Food> list = healthInterventionDao.queryFood();
        return list;
    }

    @Override
    public Boolean verifyOrderStatus(Integer id) {
        String orderStatus = healthInterventionDao.verifyOrderStatus(id);
        if(orderStatus.equals("未到诊")){
            return false;
        }else {
            return true;
        }
    }

    @Override
    public Boolean verifyIntervention(Integer id) {

        List<Intervention> intervention = healthInterventionDao.verifyIntervention(id);
        if(intervention.size()>0){
            return false;
        }else {
            return true;
        }
    }

    @Override
    public Integer addIntervention(Intervention intervention) {

        Integer i = healthInterventionDao.addIntervention(intervention);
        Integer id = intervention.getId();
        return id;
    }

    @Override
    public void addInterventionAndExercise(Integer interventionId, Integer[] sportIds) {
        for (Integer sportId : sportIds) {
            healthInterventionDao.addInterventionAndExercise(interventionId,sportId);
        }
    }

    @Override
    public void addInterventionAndFood(Integer interventionId, Integer[] foodIds) {
        for (Integer foodId : foodIds) {
            healthInterventionDao.addInterventionAndFood(interventionId,foodId);
        }
    }

    @Override
    public List<String> queryAdvice(Integer id) {
        return  healthInterventionDao.queryAdvice(id);
    }

    @Override
    public List<Integer> queryExerciseByIntervention(Integer interventionId) {
        return healthInterventionDao.queryExerciseByIntervention(interventionId);
    }

    @Override
    public List<Integer> queryFoodByIntervention(Integer interventionId) {
        return healthInterventionDao.queryFoodByIntervention(interventionId);
    }

    @Override
    public Integer queryInterventionId(Integer id) {
        return healthInterventionDao.queryInterventionId(id);
    }

    @Override
    public void deleteIntervention(Integer orderId) {
        healthInterventionDao.deleteIntervention(orderId);
    }

    @Override
    public void deleteInterventionAndExercise(Integer id) {
        healthInterventionDao.deleteInterventionAndExercise(id);
    }

    @Override
    public void deleteInterventionAndFood(Integer id) {
        healthInterventionDao.deleteInterventionAndFood(id);
    }
}
